$().ready(function() {
	function findValueCallback(event, data, formatted) {
		$("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result");
	}
	
	function formatItem(row) {
		return row[0] + " (<strong>id: " + row[1] + "</strong>)";
	}
	function formatResult(row) {
		return row[0].replace(/(<.+?>)/gi, '');
	}
	$.ajax({
		type : "Post",
		url : __ctxPath
				+ "/front/index.do?cmd=initCity",
		dataType : "json",
		async:true,
		success : function(citys) {
		$("#arrCity").autocomplete(citys, {
				minChars: 0,
				width: 240,
				matchContains: true,
				autoFill: false,
				multiple :true,// 多个选择
				formatItem: function(row, i, max) {
					return row.name +" "+  row.code  +" "+ row.eName  ;
				},
				formatMatch: function(row, i, max) {
					return row.name +" "+  row.code  +" "+ row.eName  ;
				},
				formatResult: function(row) {
					return row.code;
				}
			});
	
	$("#dpt").autocomplete(citys, {
		minChars: 0,
		width: 240,
		matchContains: true,
		autoFill: false,
		multiple :true,// 多个选择
		formatItem: function(row, i, max) {
			return row.name +" "+  row.code  +" "+ row.eName  ;
			},
		formatMatch: function(row, i, max) {
			return row.name + " " + row.code;
		},
		formatResult: function(row) {
			return row.code;
		}
	});
	},
		error : function() {
			//alert('获取城市名称失败!');
		}
	});
	$(":text, textarea").result(findValueCallback).next().click(function() {
		$(this).prev().search();
	});
	
});